<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>scheme.h</title>
<style type="text/css">
<!--
body.hl	{ background-color:#ffffff; }
pre.hl	{ color:#000000; background-color:#ffffff; font-size:10pt; font-family:'Courier New';}
.hl.num { color:#ff0000; }
.hl.esc { color:#ff22ff; }
.hl.str { color:#ff0000; }
.hl.dstr { color:#ff0000; }
.hl.slc { color:#0000ff; }
.hl.com { color:#0000ff; }
.hl.dir { color:#ff22ff; }
.hl.sym { color:#000000; }
.hl.line { color:#0000ff; }
.hl.mark	{ background-color:#ffffbb;}
.hl.kwa { color:#b26818; }
.hl.kwb { color:#00ff00; }
.hl.kwc { color:#b26818; }
.hl.kwd { color:#000000; }
//-->
</style>
</head>
<body class="hl">
<pre class="hl"><span class="hl dir">#include &lt;stdio.h&gt;</span>
<span class="hl dir">#include &lt;stdlib.h&gt;</span>
<span class="hl dir">#include &lt;string.h&gt;</span>

<span class="hl com">/* allocate space for type t */</span>
<span class="hl dir">#define new( t ) ((t *) malloc( sizeof( t ) ))</span>

<span class="hl com">/* basic pair */</span>
<span class="hl kwc">typedef</span> <span class="hl kwb">struct</span> pair <span class="hl sym">{</span>
    <span class="hl kwb">struct</span> pair <span class="hl sym">*</span>car<span class="hl sym">;</span>
    <span class="hl kwb">struct</span> pair <span class="hl sym">*</span>cdr<span class="hl sym">;</span>
<span class="hl sym">}</span> Pair<span class="hl sym">;</span>

<span class="hl kwc">typedef</span> Pair <span class="hl sym">* (*</span>PF<span class="hl sym">)();</span>  <span class="hl com">/* function pointer type */</span>

<span class="hl com">/*</span>
<span class="hl com"> * atoms</span>
<span class="hl com"> *   An atom is a pair with the car set to one of the special symbols below.</span>
<span class="hl com"> *   PROVISIONAL DESIGN: nil is special, and is represented by 0 = NULL</span>
<span class="hl com"> */</span>
<span class="hl dir">#define SYMBOL ((Pair *) 1)</span>
<span class="hl dir">#define FIXNUM ((Pair *) 2)</span>
<span class="hl dir">#define FLOAT  ((Pair *) 3)</span>
<span class="hl dir">#define DOUBLE ((Pair *) 4)</span>
<span class="hl dir">#define PNAME  ((Pair *) 5)</span>
<span class="hl dir">#define VALUE  ((Pair *) 6)</span>
<span class="hl dir">#define FUNC   ((Pair *) 7)</span>
<span class="hl dir">#define LAMBDA ((Pair *) 8)</span>
<span class="hl dir">#define ATOM             9</span>

<span class="hl dir">#define is_fixnum( p ) (p-&gt;car == FIXNUM)</span>
<span class="hl dir">#define nval( p ) ((long) p-&gt;cdr)</span>  <span class="hl com">/* extract the numeric value */</span><span class="hl dir"></span>

<span class="hl dir">#define is_double( p ) (p-&gt;car == DOUBLE)</span>
<span class="hl dir">#define dval( p ) (*(double *) (p-&gt;cdr))</span>

<span class="hl dir">#define is_number( p ) (p-&gt;car == FIXNUM || p-&gt;car == DOUBLE)</span>

<span class="hl dir">#define is_symbol( p ) (p-&gt;car == SYMBOL)</span>
<span class="hl dir">#define is_func( p ) (p-&gt;car == FUNC)</span>
<span class="hl dir">#define is_lambda(p) (p-&gt;car==LAMBDA)</span>
<span class="hl dir">#define atom(p) (p==NULL||(int)p-&gt;car&lt;ATOM)</span>

<span class="hl dir">#define CADR(p) (p-&gt;cdr-&gt;car)</span>
<span class="hl dir">#define CADDR(p) (p-&gt;cdr-&gt;cdr-&gt;car)</span>

<span class="hl dir">#include</span> <span class="hl dstr">&quot;init.h&quot;</span><span class="hl dir"></span>
<span class="hl dir">#include</span> <span class="hl dstr">&quot;reader.h&quot;</span><span class="hl dir"></span>
<span class="hl dir">#include</span> <span class="hl dstr">&quot;globals.h&quot;</span><span class="hl dir"></span>
<span class="hl dir">#include</span> <span class="hl dstr">&quot;printer.h&quot;</span><span class="hl dir"></span>
<span class="hl dir">#include</span> <span class="hl dstr">&quot;eval.h&quot;</span><span class="hl dir"></span>
<span class="hl dir">#include</span> <span class="hl dstr">&quot;prim.h&quot;</span><span class="hl dir"></span>
<span class="hl dir">#include</span> <span class="hl dstr">&quot;util.h&quot;</span><span class="hl dir"></span>

</pre>
</body>
</html>
<!--HTML generated by highlight 2.6.14, http://www.andre-simon.de/-->
